package com.mas.session.state;

import jade.lang.acl.ACLMessage;

import com.mas.common.Consts;
import com.mas.session.Session;
import com.mas.strategey.Proposal;
import com.thoughtworks.xstream.XStream;

public class RejectExitSenderState extends ExitState {

	private Proposal proposal;

	public RejectExitSenderState(Session session) {
		super(session);
	}

	/**
	 * this method is being called only if reject proposal message should be
	 * sent. since there is no acknowledge/reply to reject message this method
	 * do not wait for reply.
	 * 
	 * @see com.mas.session.state.AbstractState#rejectProposalResponse(jade.lang.acl.ACLMessage)
	 */
	public void sendRejectProposalResponse(ACLMessage message) {
		ACLMessage reply = message.createReply();

		XStream xstream = new XStream();

		reply.setContent(xstream.toXML(Consts.PROPOSAL_REJECTED_MSG));
		reply.setPerformative(ACLMessage.REJECT_PROPOSAL);
		this.session.getAgent().send(reply);

		exit(message, "Proposal rejected by:"
				+ session.getAgent().getLocalName());
	}

	/**
	 * @return the proposal
	 */
	public Proposal getProposal() {
		return proposal;
	}

	/**
	 * @param proposal
	 *            the proposal to set
	 */
	public void setProposal(Proposal proposal) {
		this.proposal = proposal;
	}
}